package com.me.study.rabbitmq.service;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Map;

@Component
public class DirectReceiverNNN {

    @RabbitListener(queues = "TestNNNDirectQueue")//监听的队列名称 TestDirectQueue
    public void process(Message message, Channel channel) {
        System.out.println("DirectReceiverNNN 消费者收到消息  : " + message.toString());
        Long deliveryTag = message.getMessageProperties().getDeliveryTag();

        try {
            channel.basicAck(deliveryTag,false);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}